<template>
  <el-tag v-if="matched" size="small" :type="matched.value">
    {{ matched.label }}
  </el-tag>
</template>

<script setup>
const props = defineProps({
  type: {
    type: Array,
    default: () => [],
  },
  code: {
    type: Object,
    default: () => ({}),
  },
});

const { code, type } = toRefs(props);
const matched = computed(() => {
  if (!code.value?.value) return null;
  const match = type.value.find((item) => item.label === code.value.value);
  return match ? { ...match, label: code.value.label } : null;
});
</script>